home *** CD-ROM | disk | FTP | other *** search
- /*
- MAIN_C - QL-Kermit main program
-
- Based on ckcmai.c, (C) Columbia University
-
-
- This Kermit program loosely based on C-Kermit (Unix version),
- (C) 1985 Trustees of Columbia University in the City of New York.
- Standard Kermit copyright conditions apply to these files.
-
- Original QL version by Robert Coughlan, Department of Surgery,
- Liverpool University.
-
- This much expanded and improved version by Jonathan Marten, May 1987.
-
- */
-
-
- /* Program version */
-
- char *vers = "QL-Kermit Version 1.10, 4-May-87";
-
-
- /* Include files */
-
- #include "ram1_ker_h" /* Kermit definitions */
-
-
- /* Global variables */
-
- int slen = DSPSIZ; /* Biggest packet we can send */
- int rlen = DRPSIZ; /* Biggest we want to receive */
- int rtmo = DMYTIM; /* Timeout interval I use */
- int stmo = URTIME; /* Timeout I want you to use */
- int delay = DDELAY; /* Delay before SEND starts */
- int npad = 0; /* Amount of padding remote needs */
- int debug = DBOFF; /* Debug display flag */
- int xfertyp = FTASC; /* File transfer type */
- int retry = MAXTRY; /* Retry limit */
- int trans = FNNORM; /* File name translation */
- int serno = -1; /* Port in use (ser1, ser2) */
- int parity = PYNONE; /* Current parity setting */
- int speed = -1; /* Current line speed */
-
- int tnpad; /* Padding count in use */
- int tvalue; /* Current packet read timeout */
- int tslen; /* Send size in use */
- int tlevel; /* TAKE file nesting level */
- int numtry; /* Packet retry count */
- int oldtry; /* Saved retry count */
- int ttychid; /* Console's QDOS channel ID */
- int ttyfd; /* Console's level 2 descriptor */
- int size; /* Output packet data size */
- int state = 0; /* Switcher state */
- int fp = -1; /* Transfer file */
- int oserr; /* Copy of QDOS error code */
-
- long filein; /* File bytes received */
- long fileout; /* File bytes sent */
- long totin; /* Batch bytes received */
- long totout; /* Batch bytes sent */
-
- bool timer = TRUE; /* Timer enabled flag */
- bool echo = FALSE; /* Local-echo flag */
- bool local = FALSE; /* System mode flag */
- bool keep = FALSE; /* Incomplete file action */
- bool tkecho = TRUE; /* Show TAKE file commands */
- bool tkabort = TRUE; /* Abort TAKE files on error */
-
- bool ebqflg; /* Doing 8-bit quoting */
- bool cxseen; /* Flag for cancelling file */
- bool czseen; /* Flag for cancelling batch */
- bool toscr; /* Data destination flag */
- bool warn8; /* Lost 8th bit warning given */
-
- char seol = MYEOL; /* EOL character to send */
- char reol = MYEOL; /* Initial EOL for receive */
- char quote = '#'; /* Control quote prefix */
- char pebq = '&'; /* 8-bit quote prefix */
- char ssop = SOH; /* Outbound packet-start character */
- char rsop = SOH; /* Incoming packet-start character */
- char enter[2] = { '\r',0 }; /* What ENTER sends */
-
- char tquote; /* Control prefix in use */
- char tseol; /* EOL character in use */
- char ebq; /* 8-bit prefix in use */
-
- char type; /* Current packet type */
- char stype; /* Server command to be sent */
-
- char sndpkt[MAXPACK*2]; /* Entire packet being sent */
- char recpkt[RBUFL]; /* Packet most recently received */
- char data[MAXPACK+4]; /* Packet data buffer */
-
- char *newfilnam = " "; /* Current filename */
- char *sourdev = " "; /* Source device */
- char *destdev = " "; /* Destination device */
- char *takedev = " "; /* TAKE file device */
- char *suffix = " "; /* Outgoing file suffix */
- char *errdata = " "; /* Data for E packet */
- char *ttyname = " "; /* Name of communication line */
-
- char *dummy = " "; /* This cures an obscure bug */
-
- char *cmarg = " ";
- char *cmarg2 = " ";
-
- unsigned char padch = '\0'; /* Padding character remote needs */
-
- unsigned char tpadc; /* Padding character in use */
-
- FILE *tfile[MAXTAKE]; /* TAKE file stack */
-
-
- /* Library routine control */
-
- int _mneed = 10240; /* 10K - ample workspace? */
- int _iomode = 0x8000; /* Level-1 files RAW mode */
- int _fmode = 0x8000; /* Level-2 files also */
-
- extern int _oserr; /* QDOS error code */
-
-
- /* External functions */
-
- bool switcher(); /* Kermit protocol switcher */
-
-
- /* MAIN - QL-Kermit main program */
-
- main()
- {
- bool stat = TRUE; /* Switcher return code */
-
- namepatch(); /* Put up a proper job name */
-
- strcpy(sourdev,"flp2_"); /* Set up default devices */
- strcpy(destdev,"flp2_");
- strcpy(takedev,"flp1_");
- strcpy(suffix,"");
-
- strcpy(ttyname,""); /* Unset line (remote mode) */
- sd_cure(fgetchid(stdout),-1); /* Enable screen cursor */
-
- cmdini(); /* Initialize command parser */
-
- forever
- {
- parser(stat); /* Parse a command */
- if (state!=0)
- {
- stat = switcher(state); /* Enter protocol if requested */
- printf("Transfer %s\n",stat ? "complete" : "failed");
- }
- }
- }
-